import java.util.Scanner;

public class Array {

    public Array() { }

    public void Init()
    {
        System.out.println("输入数组元素个数");
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        a = new int[n];
        System.out.println("输入"+n+"个整数作为数组元素");
        for (int i = 0; i < a.length; ++i)
        {
            a[i] = input.nextInt();
        }
    }

    public void Insert()
    {
        System.out.println("请输入要插入元素的位置");
        Scanner input = new Scanner(System.in);
        int location = input.nextInt();


        if (location < 0 || location > a.length)
        {
            System.out.println("输入位置有误");
            return;
        }

        int b[] = new int[a.length + 1];

        System.arraycopy(a, 0, b, 0, location);

        System.arraycopy(a, location, b, location + 1, a.length - location);

        System.out.println("请输入要插入的整数");
        int elem = input.nextInt();
        b[location] = elem;
        a = new int[b.length];
        System.arraycopy(b, 0, a, 0, b.length);
    }


    public void Delete()
    {
        System.out.println("请输入要删除元素的位置");
        Scanner input = new Scanner(System.in);
        int location = input.nextInt();


        if (location < 0 || location > a.length-1)
        {
            System.out.println("输入位置有误");
            return;
        }

        int b[] = new int[a.length - 1];

        System.arraycopy(a, 0, b, 0, location);

        System.arraycopy(a, location + 1, b, location, a.length - location -1);

        a = new int[b.length];
        System.arraycopy(b, 0, a, 0, b.length);
    }


    public void Print()
    {
        System.out.println("输出数组为");
        for (int i = 0; i < a.length; ++i)
        {
            System.out.print(a[i]);
        }
        System.out.println();
    }
    public static void main(String[] args) {

        Array x = new Array();

        x.Init();
        x.Print();
        x.Insert();
        x.Print();
        x.Delete();
        x.Print();
    }
    private int n;
    private int a[];
}